package App.Controller;

import App.Model.BaseEnum;
import App.Model.BaseResponse;
import App.Model.DataResponse;
import App.Model.Fee.*;
import App.Service.FeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by xw on 2020/3/11.
 */


@RestController
@RequestMapping("/api/fee/")
public class FeeController extends BaseController {

    @Autowired
    private FeeService _service;


    //完成任务
    @RequestMapping("lawer")
    public ResponseEntity<BaseResponse> getLawFee(@RequestBody(required = false) GetLawFeeRequest _request) throws Exception {

        if (_request == null) {
            BaseResponse _baseResponse = ResponseError(null, "参数格式错误");
            return new ResponseEntity(_baseResponse, HttpStatus.OK);
        }

        GetLawFeeResponse _result = _service.getFee(_request, userId());
        BaseResponse _baseResponse = ResponseError(null, "参数格式错误");
        _baseResponse.setMessage("操作成功");
        _baseResponse.setSuccess(BaseEnum.ApiResult.Success.getApiResult());
        _baseResponse.setData(_result);

        return new ResponseEntity(_baseResponse, HttpStatus.OK);
    }

    @RequestMapping("case")
    public ResponseEntity<?> GetLawerCase(@RequestBody(required = false) GetCaseRequest _request) {
        DataResponse _dataResponse = new DataResponse();
        try {
            List<CrmCase> _result = _service.GetLawerCase(_request, userId());
            _dataResponse.setData(_result);
        } catch (Exception ex) {
            ex.printStackTrace();

        }
        return new ResponseEntity(_dataResponse, HttpStatus.OK);
    }

        @RequestMapping("litigation")
        public ResponseEntity<BaseResponse> getLitigationFee(@RequestBody(required = false) GetLitigationFeeRequest _request) throws Exception {

            if (_request == null) {
                BaseResponse _baseResponse = ResponseError(null, "参数格式错误");
                return new ResponseEntity(_baseResponse, HttpStatus.OK);
            }

            GetLitigationFeeResponse _result = _service.getLitigationFee(_request, userId());
            BaseResponse _baseResponse = ResponseError(null, "参数格式错误");
            _baseResponse.setMessage("操作成功");
            _baseResponse.setSuccess(BaseEnum.ApiResult.Success.getApiResult());
            _baseResponse.setData(_result);

            return new ResponseEntity(_baseResponse, HttpStatus.OK);
        }


}